use std::{ptr::null_mut, sync::atomic::AtomicUsize};

use crate::{constants::MI_PAGE_QUEUES_EMPTY, types::{MiHeap, MiPage, MiPageFlags, MiRandomCxt, MI_BIN_FULL}};


impl MiHeap {
    pub const unsafe fn empty() -> Self {
        Self { tld: null_mut(), thread_delayed_free: AtomicUsize::new(0), thread_id: 0, arena_id: 0, cookie: 0, keys: [0, 0], random: MiRandomCxt { input: [0; 16], output: [0; 16], output_available: 0, weak: true }, page_count: 0, page_retired_min: MI_BIN_FULL, page_retired_max: 0, next: null_mut(), no_reclaim: false, tag: 0, pages_free_direct: [(&mut  _mi_page_empty) as *mut MiPage;128+1], pages: MI_PAGE_QUEUES_EMPTY }
    }
}

pub const _mi_heap_empty: MiHeap = unsafe {
    MiHeap::empty()
};  // read-only empty heap, initial value of the thread local default heap

impl MiPage {
    pub const fn empty() -> Self {
        Self { segment_idx: 0, segment_in_use: false, is_committed: false, is_zero_init: false, is_huge: false, capacity: 0, reserved: 0, flags: MiPageFlags::FullAligned(0), free_is_zero: false, retire_expire: 0, free: null_mut(), local_free: null_mut(), used: 0, block_size_shift: 0, heap_tag: 0, block_size: 0, page_start: null_mut(), xthread_free: AtomicUsize::new(0), xheap: AtomicUsize::new(0), next: null_mut(), prev: null_mut() }
    }

}

pub static mut _mi_page_empty: MiPage = MiPage::empty();

pub fn mi_thread_init() {
    unimplemented!()
}